package com.wtwd.campus.attendancenetty;


import com.wtwd.campus.utils.BinaryUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

// MessageToByteEncoder<I> 中的泛型表示原数据类型
public class MessageEncoder extends MessageToByteEncoder<Object> {
    @Override
    public void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out)
            throws Exception {
        byte[] bytes = BinaryUtil.hexStr2Byte(msg.toString());
        out.writeBytes(bytes);
    }
}
